<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<title>login</title>
		<link href="../../css/mui.min.css" rel="stylesheet" type="text/css" />
		<link href="../../css/app.css" rel="stylesheet" type="text/css" />
	</head>

	<body id='app'>
		<header class="mui-bar mui-bar-nav">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <h1 class="mui-title">注册</h1>
		</header>
				<div class="mui-content">
			<form class="mui-input-group">
				<div class="mui-input-row" style="margin-top: 35px">
					<input id='account' type="text" class="mui-input-clear mui-input" placeholder="请输入用户名">
				</div>
				<div class="mui-input-row">
					<input id='email' type="text" class="mui-input-clear mui-input" placeholder="请输入绑定邮箱">
				</div>
				<div class="mui-input-row">
					<input id='password' type="password" class="mui-input-clear mui-input" placeholder="请输入密码(请填写6~16位密码)">
				</div>
				<div class="mui-input-row">
					<input id='password2' type="password" class="mui-input-clear mui-input" placeholder="请确认密码">
				</div>				
			</form>
			<div class="mui-content-padded">
				<button @tap='reg' id='reg' class="mui-btn main-btn-block">注册</button>
			</div>
		</div>
		<script src="../../js/mui.min.js"></script>
		<script src="../../js/mui-extend.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/vue.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/app.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			mui.init();
			var vm = new Vue({
				el:'#app',
				ready:function(){
					mui.plusReady(function () {
						showPage(plus.webview.currentWebview());
					})
				},
				methods:{
					reg:function () {
						var account = document.getElementById("account").value;
						if(tool.isEmptyVal(account)){
							mui.toast("请输入用户名")
							return;
						}
						var email =document.getElementById("email").value;
						console.log(email);
						if(!tool.isEmail(email)){
							mui.toast("请输入绑定邮箱")
							return;
						}
						var password = document.getElementById("password").value;
						if(tool.isEmptyVal(password)){
							mui.toast("请输入密码");
							return;
						}
						if(password.length<6 || password.length>12){
							mui.toast("密码长度不对");
							return;
						}
						var password2 = document.getElementById("password2").value;
						if(tool.isEmptyVal(password2)){
							mui.toast("请输入确认密码");
							return;
						}
						if(password2.length<6 || password2.length>16){
							mui.toast("确认密码长度不对");
							return;
						}
						if(password !== password2){
							mui.toast("密码不一致");
							return;
						}
						ajax.post(api.user.register,{
							UserName: account,
							Email:email,
							Password:password,
						},function () {
							mui.alert("注册成功！请前往邮箱激活您的账号。","学园","确定",function () {
								plus.webview.currentWebview().close();
							})
						},true)
					}
				}
			})
		</script>
	</body>

</html>